<?php


    // Author: Tomasz Durka
    // Date: 6th February 2007
    // Prints out a PHP nails form
    
    
  function form (array $params = array()) {  
    $module = module;
    $action = action;
    $parameter = false;
    $method = 'post';
    $name = '';
    $id = '';
    $class = '';
    $style = '';
    $before = '';
    $enctype = '';
    $location = false;
    $target = '';
    if (!isset($params['module']) && !isset($params['action']) && !isset($params['parameter'])) {
      $path_to = '';
    }
    
    foreach($params as $_key => $_val) {
      switch ($_key) {
        case 'name':
        case 'id':
        case 'class':
        case 'style':
        case 'enctype':
        case 'target':
          $$_key = $_key . '="' . $_val . '" ';
          break;
        case 'before':
          $$_key = " onSubmit=\"{$_val}\"";
          break;
        case 'location':
        case 'url':
            $location = '/' . $_val;
          break;
        default:
          $$_key = $_val;
          break;
      }
    }
    
    
    if ($location) {
      $path_to = $location;
    } else {
      $path_to = isset($path_to) ? $path_to : '' . '/' . $module . '/' . $action . '/' . $parameter;
    }

    $returned = '<form method="' . $method . '" ' . 'action="' . $path_to . '" ' . $name . $id . $class . $style . $enctype . $before . $target . '>';
    return $returned;
  }

?>
